Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1117216ybh; Sat, 14 Mar 2020 18:31:00 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu5YPj9Uop81nh4VpCdTytsPBq3hnSp8NlvJHjmj1u0umRdHv6xCyCmRSnadJboRqYpPaCo X-Received: by 2002:aca:ec49:: with SMTP id k70mr13018543oih.80.1584235860357; Sat, 14 Mar 2020 18:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584235860; cv=none; d=google.com; s=arc-20160816; b=tJCTS1G+ACfM/JBKTy3lzKBCTMLyTbrfo3CKcQsrJ13YMGm2zbgTPtn43/GFanlpAN oyTIl14t4pq7AZJZ2w5omoDV2/VSYXuiunGYavmOBaUjFGOPC+vg3nyL6Z5xPJhDMVjs qS3gzTbcOr8rGzjUFEEy5eCsWiTAuBAmxhlXFYPVdkpIE4sPFn2GMr9ZvFdUAhp6D/6z UPgW6Cs/Voqd7g2oc80pdWVui3jPgw5Bzjhd1su72RL0jYR/5ywNyr0Px34cGYA00UCt Xh29Enwk3N4JI1YmEdViMOoHA4ZNrFvYGRjmQ3AC3qRZDsQIgon2/OiYExAvc/xuWTXB gIUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=jV5tZ1v/p9xuQRyV8rZQ6DHYjtqoRajw8WCeLW9xLgk=; b=HMdX4rE6xt9vp49a3CuwzAAUvZvd/xkfQ7HW1oD8kTjA/vXWxMgodcAFEkPrh2QuBw dfJLyETH6DE/iIqT6MiQ1oDmuawMDOap7StsVod8qgvvIKMUetFKVu/J9Zik1FM2/3na XmS1/60sPrchwZULPL7j9mEDmAsrp5OT68XdLLLbt5GNwsdE19RImvxJCE8HFB8mY4sp RGVN4m9THYyhyywMM1NbrwL4bYh4csG06vkuXGIdjIzleipN3AaoSYpgy5fqlYj9Nh0+ 2SJWubg/OqIe7j5fhWzFp5/MpRpgJf6DkD4wfRH8oEuzGCTs2Ot6LgpyH+Xc7BiBiKO6 JTgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ggxtvo43; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6si7665662otq.50.2020.03.14.18.30.31; Sat, 14 Mar 2020 18:31:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ggxtvo43; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726893AbgCOB3g (ORCPT + 99 others); Sat, 14 Mar 2020 21:29:36 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37169 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbgCOB3b (ORCPT ); Sat, 14 Mar 2020 21:29:31 -0400 Received: by mail-wm1-f67.google.com with SMTP id a141so14232612wme.2 for ; Sat, 14 Mar 2020 18:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=jV5tZ1v/p9xuQRyV8rZQ6DHYjtqoRajw8WCeLW9xLgk=; b=Ggxtvo43ajRmI5XCMihEXXh5QNfPP23IGgGAQofyo4EoerWACwkSgJUcxjU/ijSMWo 60T9pSBznVoXwlbAs0KCk1QLA8RCHEhiukgDi9GW5j0nQnAse7PG58dm+HH1MyY9B/iU kzQj+KfJLboan5g4H2QR3ZbMdzCjtccJMnDMyIYlLTjmrETLv11gbCWyHqtvNG9wSdzn LkGxuFsXEPb8X2PWZ17NJCWvfVVwzQGIuiskbmyPUKJLCji+M+Y91B7l645s+2m+7I7Q LTiAWBKL/lnfhv9ZYkVrUX9KJyc53tinFNgyLw0nUD7Xy9tkkV0CRj60MELGerw2iw43 SpvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jV5tZ1v/p9xuQRyV8rZQ6DHYjtqoRajw8WCeLW9xLgk=; b=acOGRUFNrA8X7FDmerFT70sSv/z0ktDvf0a4jqmMTc2zpDSzyLw7pmO+m4MFmuuIsR VwgV4baiEw9TKyIVEX/F0Zv61NmFsCCyvWO9CDsggyAosCwdb6VsG3NoTpPH2l/n6VYl JXRRZ7ZKQRMb0Wv8HWAwqKXWt+NdSvHcGP9iDDf7dUA6El8RKpZGky+Y7JA+ItfWSoZi la/TTjYc93zz4Kx7hQVBHNrFk3NyaqGBn7Hv/0auvncbjcceTnk6ieRv5urP2q4hLKg4 ffr0WST7vYfuOP3Nx8wbhXlz06yNuUwm4Ct7aDsTAkoXGhRhYBaz0ZXtPFscGUJReuy6 XPTg== X-Gm-Message-State: ANhLgQ3cat7XnkKgJY2U2ElgZhQ+dj566qqkFhZAGDepEqD+0j74wJVu HM3HeyGkb+aNPzw/kMYr5Tk= X-Received: by 2002:a1c:1b4c:: with SMTP id b73mr18403017wmb.17.1584235769447; Sat, 14 Mar 2020 18:29:29 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id i6sm22802683wru.40.2020.03.14.18.29.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 14 Mar 2020 18:29:28 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang , Matthew Wilcox Subject: [Patch v2] mm/swap_state.c: use the same way to count page in [add_to|delete_from]_swap_cache Date: Sun, 15 Mar 2020 01:29:20 +0000 Message-Id: <20200315012920.2687-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function add_to_swap_cache() and delete_from_swap_cache() are counter parts, while currently they use different way to count page. It doesn't break any thing because we only have two size for PageAnon, but this is confusing and not a good practice. This patch corrects it by both using hpage_nr_pages(). Signed-off-by: Wei Yang CC: Matthew Wilcox --- v2: change to hpage_nr_pages() which is opt. suggested by Matthew Wilcox --- mm/swap_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index 8e7ce9a9bc5e..ebed37bbf7a3 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -116,7 +116,7 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp) struct address_space *address_space = swap_address_space(entry); pgoff_t idx = swp_offset(entry); XA_STATE_ORDER(xas, &address_space->i_pages, idx, compound_order(page)); - unsigned long i, nr = compound_nr(page); + unsigned long i, nr = hpage_nr_pages(page); VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(PageSwapCache(page), page); -- 2.23.0