From patchwork Fri Sep 17 16:47:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12502809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75800C433EF for ; Fri, 17 Sep 2021 17:20:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 18A5561212 for ; Fri, 17 Sep 2021 17:20:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 18A5561212 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A9DB66B0072; Fri, 17 Sep 2021 13:20:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A4D336B0073; Fri, 17 Sep 2021 13:20:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 914E3900002; Fri, 17 Sep 2021 13:20:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id 7ED806B0072 for ; Fri, 17 Sep 2021 13:20:14 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 43DE318512000 for ; Fri, 17 Sep 2021 17:20:14 +0000 (UTC) X-FDA: 78597728748.40.541A9C3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf16.hostedemail.com (Postfix) with ESMTP id C4F52F40B05A for ; Fri, 17 Sep 2021 16:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631897284; h=from:from: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; bh=4hCdvDjRviIL22W5JADBBQycRMaHOvY6mSdPWhIlWZU=; b=JdKxIIaxcCQH0zK0PYTA1iqhIyOkRFobas7p2iahC+X2J9c7gXYuCpc5/gwpo+6zLtdC1q hqjfZdrGRBXv1D42fFbbLbwCkQe/KBz0egCuBryud8ZFEX9Yc7+DkbQwuzoENWKNy06dQZ fmiaQlLZgv02KHY0Rd+RGBPa0x1Yaic= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-xcNldY8BPmeOg1JgH-9Pvg-1; Fri, 17 Sep 2021 12:48:03 -0400 X-MC-Unique: xcNldY8BPmeOg1JgH-9Pvg-1 Received: by mail-qv1-f71.google.com with SMTP id ci14-20020a056214054e00b0037a75ff56f9so92068305qvb.23 for ; Fri, 17 Sep 2021 09:48:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4hCdvDjRviIL22W5JADBBQycRMaHOvY6mSdPWhIlWZU=; b=iJZ1NdGTihZgSpg75t2zx7uLVFNVD7rYgoDQ92NErt1/mYV20xPSdWLgU7kIhUFiQQ DaTLRT6WsUAkTF5VOCUusTO8xnPKRx1cAD7Sq5/SDQG5+66oHyNmPsfDkxTzX9ebowQN 2n0efkaKKcclnuPRmwWZiupV0azvRhUMH5tdHgxzMlZD++jMCBec3ch45Fx+5vcMWMSi fH/vAtwai/smRmMViHqrqTh49pY0Hgftx/E6e05KK92iVkZXQPlW302NzFrLZOCiNbWT TZmGa1gIwcsKropsaPz+xeMQ+io99BSa3/XneDKTu3JTCci/ih2dzxK5guAL2Xqqtt9N wZfw== X-Gm-Message-State: AOAM532JDssR+rcj+HRzyyLjjTUGmO2CAJnxrpnx/YN35HS3tOFJwGnM ss4+w7X49Hs0aDKOTlDOsozuWlBFLLdgYvv1cK2ksAXplcoGJT3CWX90gBSQOw2Yp1sSLA15NWj zUaopJuPKfe+owUn7HaYmxJJLGgrji92jQjT+2vA7a/3hgaw98FLWqgJV321Z X-Received: by 2002:aed:3004:: with SMTP id 4mr11017163qte.407.1631897282540; Fri, 17 Sep 2021 09:48:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZWVxwXPHBVDYEfR49AslQcsKewHkeBvsRTypxwBGT/QQhAZPTJ0bzyrPxFClD91GIRnLm8A== X-Received: by 2002:aed:3004:: with SMTP id 4mr11017137qte.407.1631897282257; Fri, 17 Sep 2021 09:48:02 -0700 (PDT) Received: from t490s.phub.net.cable.rogers.com ([2607:fea8:56a2:9100::d35a]) by smtp.gmail.com with ESMTPSA id t26sm4898057qkm.0.2021.09.17.09.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Sep 2021 09:48:01 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Vlastimil Babka , Andrew Morton , Hugh Dickins , Andrea Arcangeli , peterx@redhat.com, Matthew Wilcox Subject: [PATCH 2/3] mm/smaps: Use vma->vm_pgoff directly when counting partial swap Date: Fri, 17 Sep 2021 12:47:55 -0400 Message-Id: <20210917164756.8586-3-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210917164756.8586-1-peterx@redhat.com> References: <20210917164756.8586-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C4F52F40B05A X-Stat-Signature: bynq5rfj5crpbnkursiqbxfgincum4f5 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JdKxIIax; spf=none (imf16.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1631897284-946162 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: As it's trying to cover the whole vma anyways, use direct vm_pgoff value and vma_pages() rather than linear_page_index. Cc: Vlastimil Babka Cc: Hugh Dickins Signed-off-by: Peter Xu Reviewed-by: Vlastimil Babka --- mm/shmem.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 96ccf6e941aa..d2620db8c938 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -856,9 +856,8 @@ unsigned long shmem_swap_usage(struct vm_area_struct *vma) return swapped << PAGE_SHIFT; /* Here comes the more involved part */ - return shmem_partial_swap_usage(mapping, - linear_page_index(vma, vma->vm_start), - linear_page_index(vma, vma->vm_end)); + return shmem_partial_swap_usage(mapping, vma->vm_pgoff, + vma->vm_pgoff + vma_pages(vma)); } /*