From patchwork Mon Jul 23 11:19:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 10539993 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 7F9AE1805 for ; Mon, 23 Jul 2018 11:19:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67EDA28600 for ; Mon, 23 Jul 2018 11:19:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B92428609; Mon, 23 Jul 2018 11:19: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=-2.9 required=2.0 tests=BAYES_00,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 37AC328600 for ; Mon, 23 Jul 2018 11:19:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 290A36B0006; Mon, 23 Jul 2018 07:19:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 23F0B6B000A; Mon, 23 Jul 2018 07:19:53 -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 106BD6B000C; Mon, 23 Jul 2018 07:19:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id C212F6B0006 for ; Mon, 23 Jul 2018 07:19:52 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id x2-v6so187992plv.0 for ; Mon, 23 Jul 2018 04:19:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=ctLPVpDP/xgC2pHU/YvrpFTbtXwGY3rY8ISq8eK7yoQ=; b=p8+87GwweDkTlcU77QyvVN6OcGloVEILcW9KrguA5zIwWOv9KjeYnSimykdDgpQKC9 UPV8/Mj6rHV8lp2z53DB1jfcQ7dCCSGe45VF71otqoeu9v7ojGdtw+stkMJePvkyh2dl PBKoV64WJIxKoCyZUQRGbhMgAt2tldDs2AlJGwJR0RFpjWGY9Ri0hqG6BeIfVGOSs6It HUeBE3JRhSRpVCF+4bSTNHSdOLvQQwuPODhfvhk1r+N9ase7GNe2SS1qvToxLT7FtKXh NbAgdP9XqLr/paLtr3bgFyjgf7KR1XThGK77SWoapYjW9e9GxNzs/M8pCez3Rp5crXdF cYGg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Gm-Message-State: AOUpUlFAFHUtwnc0yKRvKBwTQ0qjw7JFpZLP/dx/eHQImDUdx6cl0e2j eWWMOA/2XxBUTaFGvAHP9o8FFeE5BSUFJKo5tJNJpoxUaLrwo6ho1rV4fF6My6t+Hwvw4PqH1IN MCCArH3/n11IinfylBZdb4fCvYpRNtMUaGSNYEAW+6/BF/wMcf5grZ4YmAkCcG7LUnA== X-Received: by 2002:a65:5288:: with SMTP id y8-v6mr11753548pgp.284.1532344792498; Mon, 23 Jul 2018 04:19:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcPRASiplt79NfpRdl25c2qS76mNTinrfoFrLE33aCBFtZAsWg844xsxoWDJt5Qh/Q8+zNc X-Received: by 2002:a65:5288:: with SMTP id y8-v6mr11753505pgp.284.1532344791713; Mon, 23 Jul 2018 04:19:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532344791; cv=none; d=google.com; s=arc-20160816; b=vJ+yJCEytWP5f4lQChZeSMKmsZedW+aV5zbvb8a4BqVeXvYbB56vpyxZUo/Yh+psLP PYD6ahywewyHbrN9PoJ6WsCtAiH29kRqt2/YadMYJMCptDvYaDkODGH32m8K5BPnYXLJ 3Vb+ZxkGOK7zqPav6AR9zbpZ93d5zA8nWbvdk8tNazjNI1hErNrKW3iLHl+gbUscWkBW HqVACwn1iHnlsWgXLL7fAUWE11udQCFyMPBoULSgp7FWQzQUVQrn8aQWxbRRsisU7JSF dJK9h1HqY9bvD/BwDAfa1ReX42N9UHRyh0CPzinmxzbSjbJ95+20d/Wb7LoPv6gPqZEq UqZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ctLPVpDP/xgC2pHU/YvrpFTbtXwGY3rY8ISq8eK7yoQ=; b=CNtfmhoFAM2eKFhw/+bQK4V6VDwYyyNa8ItQen6TqAHWv4WJtkQEfRpW+WyL3hnJSo ihEEGFhr2CP7NK05vWv+aNcI8nqvKfqn9xTe4+bTzQKXpzoQYyGJr6uHODjZjYayhKBc 3jNtC4Ikm8QUUYQ8txvsRsbypkKzMCQAdHVKItZrPjo17A5ghDwES6KTDk2mdwDeFlW6 ey1ErcVZcIIGlS3NzdZOArkdcRDPmOKzKzilt9DIr4LhA8GDKHANgDWsPjVoCKC9q2XT X3x6uXnq7B1L2sFSRtlMMjl+Y7PZGWs/iGX+JUnaswjtHpNnUjDVLjvhcEQ3pG9g2ncE E19A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id v190-v6si8615556pgd.668.2018.07.23.04.19.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 04:19:51 -0700 (PDT) Received-SPF: pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D2A27AEDA; Mon, 23 Jul 2018 11:19:49 +0000 (UTC) From: Vlastimil Babka To: Andrew Morton Cc: Daniel Colascione , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexey Dobriyan , linux-api@vger.kernel.org, Vlastimil Babka Subject: [PATCH 2/4] mm: proc/pid/smaps: factor out mem stats gathering Date: Mon, 23 Jul 2018 13:19:31 +0200 Message-Id: <20180723111933.15443-3-vbabka@suse.cz> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723111933.15443-1-vbabka@suse.cz> References: <20180723111933.15443-1-vbabka@suse.cz> 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 To prepare for handling /proc/pid/smaps_rollup differently from /proc/pid/smaps factor out vma mem stats gathering from show_smap() - it will be used by both. Signed-off-by: Vlastimil Babka Signed-off-by: Vlastimil Babka --- fs/proc/task_mmu.c | 55 ++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index a3f98ca50981..d2ca88c92d9d 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -702,14 +702,9 @@ static int smaps_hugetlb_range(pte_t *pte, unsigned long hmask, } #endif /* HUGETLB_PAGE */ -#define SEQ_PUT_DEC(str, val) \ - seq_put_decimal_ull_width(m, str, (val) >> 10, 8) -static int show_smap(struct seq_file *m, void *v) +static void smap_gather_stats(struct vm_area_struct *vma, + struct mem_size_stats *mss) { - struct proc_maps_private *priv = m->private; - struct vm_area_struct *vma = v; - struct mem_size_stats mss_stack; - struct mem_size_stats *mss; struct mm_walk smaps_walk = { .pmd_entry = smaps_pte_range, #ifdef CONFIG_HUGETLB_PAGE @@ -717,23 +712,6 @@ static int show_smap(struct seq_file *m, void *v) #endif .mm = vma->vm_mm, }; - int ret = 0; - bool rollup_mode; - bool last_vma; - - if (priv->rollup) { - rollup_mode = true; - mss = priv->rollup; - if (mss->first) { - mss->first_vma_start = vma->vm_start; - mss->first = false; - } - last_vma = !m_next_vma(priv, vma); - } else { - rollup_mode = false; - memset(&mss_stack, 0, sizeof(mss_stack)); - mss = &mss_stack; - } smaps_walk.private = mss; @@ -765,6 +743,35 @@ static int show_smap(struct seq_file *m, void *v) walk_page_vma(vma, &smaps_walk); if (vma->vm_flags & VM_LOCKED) mss->pss_locked += mss->pss; +} + +#define SEQ_PUT_DEC(str, val) \ + seq_put_decimal_ull_width(m, str, (val) >> 10, 8) +static int show_smap(struct seq_file *m, void *v) +{ + struct proc_maps_private *priv = m->private; + struct vm_area_struct *vma = v; + struct mem_size_stats mss_stack; + struct mem_size_stats *mss; + int ret = 0; + bool rollup_mode; + bool last_vma; + + if (priv->rollup) { + rollup_mode = true; + mss = priv->rollup; + if (mss->first) { + mss->first_vma_start = vma->vm_start; + mss->first = false; + } + last_vma = !m_next_vma(priv, vma); + } else { + rollup_mode = false; + memset(&mss_stack, 0, sizeof(mss_stack)); + mss = &mss_stack; + } + + smap_gather_stats(vma, mss); if (!rollup_mode) { show_map_vma(m, vma);