From patchwork Sun Mar 15 01:29:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11438407 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86BDF13B1 for ; Sun, 15 Mar 2020 01:29:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5384920637 for ; Sun, 15 Mar 2020 01:29:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ggxtvo43" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5384920637 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 879E16B0005; Sat, 14 Mar 2020 21:29:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 82D4D6B0006; Sat, 14 Mar 2020 21:29:31 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 718E56B0007; Sat, 14 Mar 2020 21:29:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id 562246B0005 for ; Sat, 14 Mar 2020 21:29:31 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2C0CA3CE7 for ; Sun, 15 Mar 2020 01:29:31 +0000 (UTC) X-FDA: 76595864142.18.play32_702c48fd89d5c X-Spam-Summary: 2,0,0,db245761dd7ce30b,d41d8cd98f00b204,richard.weiyang@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3867:3868:3871:3872:4321:5007:6261:6653:7514:7903:8603:8957:9413:10004:11026:11473:11658:11914:12043:12114:12296:12297:12438:12517:12519:12555:12895:13069:13255:13311:13357:14096:14181:14384:14687:14721:21080:21444:21451:21627:21666:30054:30070,0,RBL:209.85.128.68:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: play32_702c48fd89d5c X-Filterd-Recvd-Size: 3836 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Sun, 15 Mar 2020 01:29:30 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id a5so13877764wmb.0 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=B06dZTWQUdEWKGWfFXUKhezuyPa47ns1H5HYvhqZ9JGc603WmWzJ9UGMj2a/vicrTo PcvoQd+58fxpIlItVkL35LAeyq7zVZNvrZzWq7D3AdttAH7eK4lpeqkKGcbxKClyKkGv NH23HYjl5kZ/HauIUGxPNKTKYHmFr4iKWdGmIzuOAMMq4wSoVbOC20kQPZglBAlPNhSR 6OP2Grx7ZXezNYOP99fd9N1bXTQmbUsomnhjY84hmgmkyMaLZstbjPi4M1Zm3IfyPFEt ZNJuOUxQ3SJ694ChoMYCtQ8KXLGRviUvmm/QnCG/VQgENhPo31SrO7XEu1b8HTWmlrX3 wZ6w== X-Gm-Message-State: ANhLgQ08pO0J87n9s89OQu4+roBn5Jgmy/h1shdwqEHs7hyvdMsazy0z sEy5sS/uU0vEISyDrZQNBzs= X-Google-Smtp-Source: ADFU+vsZhRwK0DE+LLHqscVM9gM+lQ91sJTeWm5Zea/fhcv+Vly6TyyRCGkXzfhH1uz8putd0WBPAw== 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 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: 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);