From patchwork Mon Jan 21 01:10:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandeep Patil X-Patchwork-Id: 10772571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DDE213B4 for ; Mon, 21 Jan 2019 01:10:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77E4929F1B for ; Mon, 21 Jan 2019 01:10:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A98729F1D; Mon, 21 Jan 2019 01:10:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F61B29F1B for ; Mon, 21 Jan 2019 01:10:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D59EB8E0003; Sun, 20 Jan 2019 20:10:52 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CE1B08E0001; Sun, 20 Jan 2019 20:10:52 -0500 (EST) 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 BAA548E0003; Sun, 20 Jan 2019 20:10:52 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 78EA18E0001 for ; Sun, 20 Jan 2019 20:10:52 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id q64so14770836pfa.18 for ; Sun, 20 Jan 2019 17:10:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:mime-version:content-transfer-encoding; bh=ucO+mEyukstSZOvX/DChuy7j9sUdkEFCR7xKzTtgKxM=; b=c3r8LNIb7FFPc7QpE68jmWFYuJi6mHSb3sh01gp+NXrHCjioQ5s8HAYQ2aC0xA2F5G srE27Sss01GxgCf6H1XR/sLo3+L1EEH91goBBP88SIutov9rJ5FxUR++wP8wKKHlu+Tl X5Z9I+KKv5/RD0GlKeyhTEdLSpxv3FXcBofxdTiwFoY7OZyd9blBVzelzMypKNLl7n0m FETZYYhHIcAk3NUc+NnQuALLOoqY3n61SoLdYU4Lp2/o8lTgDrRzPfPR11Toox22+kYT 3CWDXi92wk3/71jGMsSCj9YRBkrzQbjc8eTR0pf8IandVt1yVxe9cyK+FQVEMrAXwQN6 XWCQ== X-Gm-Message-State: AJcUukcFEfJl5UBOexbBZZ5tYIOgftoohDpiV1csquMihYVR/VOhaUu8 E2SAw1bPP3+Twe4XOD4KRcdR+z0jEI5AAsDdGlBds68R0vJ2bQEvKg9VXdSzECmXJMz6nEis0lL w/kwFV0BTf4wap/CM9twDffguIzih1kx2jfAxHx5s5MgsDOT6oQ39oMP9srddARyR13ABVvb7LN gdG1sWgSP/UDQhYAFJeESexFO8h1yo62wT7ALwiqfzT/p83D0QZqaRIzrzKVyYDfnRcxZVsaXP8 onReOyi4ZmgTZSdfY0aFZC4+hMLmmLISS2vwGjfudprMzM0K5hAjDlLtLTwrWhJmSiqUb1SCCr/ DpsKgos1stP1Gm71XxiMbe85HAo2gqtDOpKvamJuvXmAgDV8NTsb3cZAW8OgC2AH8OF8rMdrPgn Z X-Received: by 2002:a63:f615:: with SMTP id m21mr26737469pgh.428.1548033052043; Sun, 20 Jan 2019 17:10:52 -0800 (PST) X-Received: by 2002:a63:f615:: with SMTP id m21mr26737436pgh.428.1548033051336; Sun, 20 Jan 2019 17:10:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548033051; cv=none; d=google.com; s=arc-20160816; b=O46PDWtWxQHjs9biw8gVwqxF0my71l1wJcGTRcwscbDgSi4xEQ26rW9jp3qruym7T2 voi8yBfOgeIdNzZ783P8vDFqH4KeXBz3dkPLYVAuK1+ovK8LW3oATPSfr8TSgsQ5I1MN o9tM7c954uXDaxriVKP4U8Z82Lut4fYgnOMTDH3H7PGgv7Mq1o+PbqbDdp6xjOs9biF6 A58yVg9VHh5AK2nBmPRRgNCmAtSjcnUfF5OjFKdzOHRdM0uilvmqKeGJEYRFB2B3tKBu KqJmvvZy9qPPXQNkuwkcdum1f/gUrDW1jZs9BtjnBexg0CQEwyGosnyqEBIDkSMFJuyJ ILAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=ucO+mEyukstSZOvX/DChuy7j9sUdkEFCR7xKzTtgKxM=; b=C1nl01pgCrwJyueEbG/SLghRXy9HRGDUPFC/UZ0yV46jwlBsQi6Scm5F9Nluw6qB1j g3h28AwChw970jY/Hx922tk7Z2L3Q1MlPTAwM0hMkydhUrjAIAUZL6LJEoAjryeEIkQ8 u7Xd+raKvMdKIeQQ5tJ8yub+26PY41FLumiTPLRn9Y+dhsXSlpisz8xMiRe87hyFb/iL qRoexUyxJ8srWPfjf5PdEHYsNKET7fPnOtBNIi9dMUucca2r27VctZrBtGc/mcGS608L z0xbQ41dC+4lFwhuE8o2wqMe3MVXuS9P9SDtfFGBozsT9cDaLYLB0YvOLC6vsp/S2Cp6 2LKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=vOEFLvDi; spf=pass (google.com: domain of sspatil@android.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=sspatil@android.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id k11sor15803694pll.39.2019.01.20.17.10.51 for (Google Transport Security); Sun, 20 Jan 2019 17:10:51 -0800 (PST) Received-SPF: pass (google.com: domain of sspatil@android.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=vOEFLvDi; spf=pass (google.com: domain of sspatil@android.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=sspatil@android.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ucO+mEyukstSZOvX/DChuy7j9sUdkEFCR7xKzTtgKxM=; b=vOEFLvDifGw5avCbsCCz5QvbSdVOTDHlqRwfyD0Q1kaXsSRKWzVCqVd5gSoTO1Ph0o YzMoo3aLurhTaVY+G7Z2RdAlZKLaWyqllQCct4kQnVsGWK5kHJAysUEjR5idEIKTN9aJ b/vDe+L2zL2D5Zl0vIy6N4mM2ulQK6XHPv+pJC81HP42MqGxGwIm8u6doeoKpyfduQWX 6mBDU/gyALKpAOgPoihX4FyTLECy3P+iZCFS9wKVEczm4WSDJcAy0M8uzg2Kn1nf3l1E hRlRFGKLqfIaKtwgjDrVNToTEvB8jim9Sb3yd7HeZC39rOJK81qPfsvbZtl6enGa3DXt clKA== X-Google-Smtp-Source: ALg8bN7vzbRoRjqMbTtv/6fG2CcHXyYU9hGVxqG89Xa8OkMJDc0udiZei0505/7Y5eMeu/ePKZe9Ag== X-Received: by 2002:a17:902:be11:: with SMTP id r17mr6240646pls.308.1548033050922; Sun, 20 Jan 2019 17:10:50 -0800 (PST) Received: from sspatil-glaptop2.roam.corp.google.com (c-73-170-36-70.hsd1.ca.comcast.net. [73.170.36.70]) by smtp.gmail.com with ESMTPSA id 4sm13985132pfq.10.2019.01.20.17.10.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 17:10:50 -0800 (PST) From: Sandeep Patil To: vbabka@suse.cz, adobriyan@gmail.com, akpm@linux-foundation.org, avagin@openvz.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@android.com, dancol@google.com Subject: [PATCH] mm: proc: smaps_rollup: Fix pss_locked calculation Date: Sun, 20 Jan 2019 17:10:49 -0800 Message-Id: <20190121011049.160505-1-sspatil@android.com> X-Mailer: git-send-email 2.20.1.321.g9e740568ce-goog MIME-Version: 1.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: X-Virus-Scanned: ClamAV using ClamSMTP The 'pss_locked' field of smaps_rollup was being calculated incorrectly as it accumulated the current pss everytime a locked VMA was found. Fix that by making sure we record the current pss value before each VMA is walked. So, we can only add the delta if the VMA was found to be VM_LOCKED. Fixes: 493b0e9d945f ("mm: add /proc/pid/smaps_rollup") Cc: stable@vger.kernel.org # 4.14.y 4.19.y Signed-off-by: Sandeep Patil --- fs/proc/task_mmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index f0ec9edab2f3..51a00a2b4733 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -709,6 +709,7 @@ static void smap_gather_stats(struct vm_area_struct *vma, #endif .mm = vma->vm_mm, }; + unsigned long pss; smaps_walk.private = mss; @@ -737,11 +738,12 @@ static void smap_gather_stats(struct vm_area_struct *vma, } } #endif - + /* record current pss so we can calculate the delta after page walk */ + pss = mss->pss; /* mmap_sem is held in m_start */ walk_page_vma(vma, &smaps_walk); if (vma->vm_flags & VM_LOCKED) - mss->pss_locked += mss->pss; + mss->pss_locked += mss->pss - pss; } #define SEQ_PUT_DEC(str, val) \