From patchwork Mon Jul 23 11:19:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 10540001 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 E815B1805 for ; Mon, 23 Jul 2018 11:20:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D478B28608 for ; Mon, 23 Jul 2018 11:20:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3F0328600; Mon, 23 Jul 2018 11:20:02 +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 8C7D128600 for ; Mon, 23 Jul 2018 11:20:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC2D16B000E; 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 C29FA6B000C; 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 8A9BB6B0010; 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 36D6B6B000C for ; Mon, 23 Jul 2018 07:19:53 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id e1-v6so155982pld.23 for ; Mon, 23 Jul 2018 04:19:53 -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=vPU6XP9wOaJpqHeU2i10iyExVxyMb/myImZiYhi0vEg=; b=G1tV9w6vV9C4uvpdAAf1i1aMXUwfAO5hex0sDhTL00TpOYLnOdg2KqqGcblOGLcS70 XR2p3TQvpwUP+Gy6D0yEz9Y8nXdKd8Pf6y3pjVe6c2wHmwc5+9iOEYofT57G9fxAay1e GV7/pOaFFRaAiIvmm2w+2hLjWIVJ32Erl5PoJ7CibcyoOWc+K3EPvAKPGgCcuKJNrdms V3KHh28ONEpQfhE6iqv41zjOOm6u0i9OjJ9iXUIK/yNL8XzmKBCpDR6Q6L4INh5c+/h1 jN0B0YB4ag0ZVYcCAOrp72U8lLfU+RxY36xT1Nzhgb/aQCNwRyJfTYJWrXD22DQNxQyS 0ctw== 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: AOUpUlHPlOZvyuScTaNL0kn0UNYC9q729c3D2gQhu7vUxchbXbta29Cb pJiwDOUnvlWu2u0n1lmUzUmJB2+h8b2SiVfEflZBijWC2/VLeW96vGGGVnBdNQnzK6g+jar0fgx a5JLHQXvDG+vm/Y6L2hY2p9n1rYL7jAIK/9v67DDu/G3uxE4Yosvbah+F48Cu0O7jyw== X-Received: by 2002:aa7:824d:: with SMTP id e13-v6mr12783383pfn.97.1532344792881; Mon, 23 Jul 2018 04:19:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfAKG57OYce9qNsVk1CGI0K4H2SR9Qipn/E80ULvHdPNH3MMd6jt/SMQm/yRBl7sUfqR0RL X-Received: by 2002:aa7:824d:: with SMTP id e13-v6mr12783321pfn.97.1532344791777; 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=lsX3lJM1WEQJTGkC7sMHSRtVr9UocMWyP7z18C11E1OGBrXUgez8spzEiOMmfuHOap DL0RNM4bWj3BdfZIPk2yGQdiR+czZuGw5gPArCJSZmyCpHaq1zR144Vak7SOMT6yAddR BoyXqZk87PQNx8Z2etFrkKwZvPMBLKsKFW2cFfgM9mupM4Ni6xYYfeZgmwDCnshKBiuU W7PuYV0mieJzhBB/Eqdf766TSrGMeM03Mzv+l3D9jIqVjJfgb3pdKtPYvIODOmVoJGVr dmb3j+uPWXlh9diT+En5+zpBTme6N1Tm/bqoJZnWZHdEo1DdsJYpXK/RHJG/looKzpaA b0mA== 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=vPU6XP9wOaJpqHeU2i10iyExVxyMb/myImZiYhi0vEg=; b=FOsPDBxeGFcQB/9NYR+lp7kss0+ddPLBW/ks5qvUcuvY2hx15ACY742wSbYnrt++4B JgLybw3QUYaYfTHMcK+3WTdXCzfcv7qUSQ8VFbPZWsk52rMgGOi+77eySDAQ+R1KkqKC 2h54Cv0Ow6J1y7LW/+w+7tPj8uLi97Ujw42kKIpXZWATkIKnhBhtsThvcX4MKPH8LkcD 63CBSRDstFCixLwupQoWhHt4i2f2n2U4+NSDPyl4E59k4m44w0wvz+lHLWIp+O3aAOSz bTUYm3316rjgoI+TXv1/2v/kE3TpHyesiC9WNEw5lV9QqTv8K2iHOd23oZfX706nXnKY rC9w== 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 e132-v6si8626691pfg.171.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 relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BF42DADDF; 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 1/4] mm: /proc/pid/*maps remove is_pid and related wrappers Date: Mon, 23 Jul 2018 13:19:30 +0200 Message-Id: <20180723111933.15443-2-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 Commit b76437579d13 ("procfs: mark thread stack correctly in proc//maps") introduced differences between /proc/PID/maps and /proc/PID/task/TID/maps to mark thread stacks properly, and this was also done for smaps and numa_maps. However it didn't work properly and was ultimately removed by commit b18cb64ead40 ("fs/proc: Stop trying to report thread stacks"). Now the is_pid parameter for the related show_*() functions is unused and we can remove it together with wrapper functions and ops structures that differ for PID and TID cases only in this parameter. Signed-off-by: Vlastimil Babka --- fs/proc/base.c | 6 +-- fs/proc/internal.h | 3 -- fs/proc/task_mmu.c | 114 +++++-------------------------------------- fs/proc/task_nommu.c | 39 ++------------- 4 files changed, 18 insertions(+), 144 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index aaffc0c30216..ad047977ed04 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -3309,12 +3309,12 @@ static const struct pid_entry tid_base_stuff[] = { REG("cmdline", S_IRUGO, proc_pid_cmdline_ops), ONE("stat", S_IRUGO, proc_tid_stat), ONE("statm", S_IRUGO, proc_pid_statm), - REG("maps", S_IRUGO, proc_tid_maps_operations), + REG("maps", S_IRUGO, proc_pid_maps_operations), #ifdef CONFIG_PROC_CHILDREN REG("children", S_IRUGO, proc_tid_children_operations), #endif #ifdef CONFIG_NUMA - REG("numa_maps", S_IRUGO, proc_tid_numa_maps_operations), + REG("numa_maps", S_IRUGO, proc_pid_numa_maps_operations), #endif REG("mem", S_IRUSR|S_IWUSR, proc_mem_operations), LNK("cwd", proc_cwd_link), @@ -3324,7 +3324,7 @@ static const struct pid_entry tid_base_stuff[] = { REG("mountinfo", S_IRUGO, proc_mountinfo_operations), #ifdef CONFIG_PROC_PAGE_MONITOR REG("clear_refs", S_IWUSR, proc_clear_refs_operations), - REG("smaps", S_IRUGO, proc_tid_smaps_operations), + REG("smaps", S_IRUGO, proc_pid_smaps_operations), REG("smaps_rollup", S_IRUGO, proc_pid_smaps_rollup_operations), REG("pagemap", S_IRUSR, proc_pagemap_operations), #endif diff --git a/fs/proc/internal.h b/fs/proc/internal.h index da3dbfa09e79..0c538769512a 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -297,12 +297,9 @@ struct proc_maps_private { struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode); extern const struct file_operations proc_pid_maps_operations; -extern const struct file_operations proc_tid_maps_operations; extern const struct file_operations proc_pid_numa_maps_operations; -extern const struct file_operations proc_tid_numa_maps_operations; extern const struct file_operations proc_pid_smaps_operations; extern const struct file_operations proc_pid_smaps_rollup_operations; -extern const struct file_operations proc_tid_smaps_operations; extern const struct file_operations proc_clear_refs_operations; extern const struct file_operations proc_pagemap_operations; diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index dfd73a4616ce..a3f98ca50981 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -294,7 +294,7 @@ static void show_vma_header_prefix(struct seq_file *m, } static void -show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) +show_map_vma(struct seq_file *m, struct vm_area_struct *vma) { struct mm_struct *mm = vma->vm_mm; struct file *file = vma->vm_file; @@ -357,35 +357,18 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) seq_putc(m, '\n'); } -static int show_map(struct seq_file *m, void *v, int is_pid) +static int show_map(struct seq_file *m, void *v) { - show_map_vma(m, v, is_pid); + show_map_vma(m, v); m_cache_vma(m, v); return 0; } -static int show_pid_map(struct seq_file *m, void *v) -{ - return show_map(m, v, 1); -} - -static int show_tid_map(struct seq_file *m, void *v) -{ - return show_map(m, v, 0); -} - static const struct seq_operations proc_pid_maps_op = { .start = m_start, .next = m_next, .stop = m_stop, - .show = show_pid_map -}; - -static const struct seq_operations proc_tid_maps_op = { - .start = m_start, - .next = m_next, - .stop = m_stop, - .show = show_tid_map + .show = show_map }; static int pid_maps_open(struct inode *inode, struct file *file) @@ -393,11 +376,6 @@ static int pid_maps_open(struct inode *inode, struct file *file) return do_maps_open(inode, file, &proc_pid_maps_op); } -static int tid_maps_open(struct inode *inode, struct file *file) -{ - return do_maps_open(inode, file, &proc_tid_maps_op); -} - const struct file_operations proc_pid_maps_operations = { .open = pid_maps_open, .read = seq_read, @@ -405,13 +383,6 @@ const struct file_operations proc_pid_maps_operations = { .release = proc_map_release, }; -const struct file_operations proc_tid_maps_operations = { - .open = tid_maps_open, - .read = seq_read, - .llseek = seq_lseek, - .release = proc_map_release, -}; - /* * Proportional Set Size(PSS): my share of RSS. * @@ -733,7 +704,7 @@ static int smaps_hugetlb_range(pte_t *pte, unsigned long hmask, #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, int is_pid) +static int show_smap(struct seq_file *m, void *v) { struct proc_maps_private *priv = m->private; struct vm_area_struct *vma = v; @@ -796,7 +767,7 @@ static int show_smap(struct seq_file *m, void *v, int is_pid) mss->pss_locked += mss->pss; if (!rollup_mode) { - show_map_vma(m, vma, is_pid); + show_map_vma(m, vma); } else if (last_vma) { show_vma_header_prefix( m, mss->first_vma_start, vma->vm_end, 0, 0, 0, 0); @@ -845,28 +816,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid) } #undef SEQ_PUT_DEC -static int show_pid_smap(struct seq_file *m, void *v) -{ - return show_smap(m, v, 1); -} - -static int show_tid_smap(struct seq_file *m, void *v) -{ - return show_smap(m, v, 0); -} - static const struct seq_operations proc_pid_smaps_op = { .start = m_start, .next = m_next, .stop = m_stop, - .show = show_pid_smap -}; - -static const struct seq_operations proc_tid_smaps_op = { - .start = m_start, - .next = m_next, - .stop = m_stop, - .show = show_tid_smap + .show = show_smap }; static int pid_smaps_open(struct inode *inode, struct file *file) @@ -893,11 +847,6 @@ static int pid_smaps_rollup_open(struct inode *inode, struct file *file) return 0; } -static int tid_smaps_open(struct inode *inode, struct file *file) -{ - return do_maps_open(inode, file, &proc_tid_smaps_op); -} - const struct file_operations proc_pid_smaps_operations = { .open = pid_smaps_open, .read = seq_read, @@ -912,13 +861,6 @@ const struct file_operations proc_pid_smaps_rollup_operations = { .release = proc_map_release, }; -const struct file_operations proc_tid_smaps_operations = { - .open = tid_smaps_open, - .read = seq_read, - .llseek = seq_lseek, - .release = proc_map_release, -}; - enum clear_refs_types { CLEAR_REFS_ALL = 1, CLEAR_REFS_ANON, @@ -1728,7 +1670,7 @@ static int gather_hugetlb_stats(pte_t *pte, unsigned long hmask, /* * Display pages allocated per node and memory policy via /proc. */ -static int show_numa_map(struct seq_file *m, void *v, int is_pid) +static int show_numa_map(struct seq_file *m, void *v) { struct numa_maps_private *numa_priv = m->private; struct proc_maps_private *proc_priv = &numa_priv->proc_maps; @@ -1812,45 +1754,17 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) return 0; } -static int show_pid_numa_map(struct seq_file *m, void *v) -{ - return show_numa_map(m, v, 1); -} - -static int show_tid_numa_map(struct seq_file *m, void *v) -{ - return show_numa_map(m, v, 0); -} - static const struct seq_operations proc_pid_numa_maps_op = { .start = m_start, .next = m_next, .stop = m_stop, - .show = show_pid_numa_map, + .show = show_numa_map, }; -static const struct seq_operations proc_tid_numa_maps_op = { - .start = m_start, - .next = m_next, - .stop = m_stop, - .show = show_tid_numa_map, -}; - -static int numa_maps_open(struct inode *inode, struct file *file, - const struct seq_operations *ops) -{ - return proc_maps_open(inode, file, ops, - sizeof(struct numa_maps_private)); -} - static int pid_numa_maps_open(struct inode *inode, struct file *file) { - return numa_maps_open(inode, file, &proc_pid_numa_maps_op); -} - -static int tid_numa_maps_open(struct inode *inode, struct file *file) -{ - return numa_maps_open(inode, file, &proc_tid_numa_maps_op); + return proc_maps_open(inode, file, &proc_pid_numa_maps_op, + sizeof(struct numa_maps_private)); } const struct file_operations proc_pid_numa_maps_operations = { @@ -1860,10 +1774,4 @@ const struct file_operations proc_pid_numa_maps_operations = { .release = proc_map_release, }; -const struct file_operations proc_tid_numa_maps_operations = { - .open = tid_numa_maps_open, - .read = seq_read, - .llseek = seq_lseek, - .release = proc_map_release, -}; #endif /* CONFIG_NUMA */ diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index 5b62f57bd9bc..0b63d68dedb2 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c @@ -142,8 +142,7 @@ static int is_stack(struct vm_area_struct *vma) /* * display a single VMA to a sequenced file */ -static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, - int is_pid) +static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma) { struct mm_struct *mm = vma->vm_mm; unsigned long ino = 0; @@ -189,22 +188,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, /* * display mapping lines for a particular process's /proc/pid/maps */ -static int show_map(struct seq_file *m, void *_p, int is_pid) +static int show_map(struct seq_file *m, void *_p) { struct rb_node *p = _p; - return nommu_vma_show(m, rb_entry(p, struct vm_area_struct, vm_rb), - is_pid); -} - -static int show_pid_map(struct seq_file *m, void *_p) -{ - return show_map(m, _p, 1); -} - -static int show_tid_map(struct seq_file *m, void *_p) -{ - return show_map(m, _p, 0); + return nommu_vma_show(m, rb_entry(p, struct vm_area_struct, vm_rb)); } static void *m_start(struct seq_file *m, loff_t *pos) @@ -260,14 +248,7 @@ static const struct seq_operations proc_pid_maps_ops = { .start = m_start, .next = m_next, .stop = m_stop, - .show = show_pid_map -}; - -static const struct seq_operations proc_tid_maps_ops = { - .start = m_start, - .next = m_next, - .stop = m_stop, - .show = show_tid_map + .show = show_map }; static int maps_open(struct inode *inode, struct file *file, @@ -308,11 +289,6 @@ static int pid_maps_open(struct inode *inode, struct file *file) return maps_open(inode, file, &proc_pid_maps_ops); } -static int tid_maps_open(struct inode *inode, struct file *file) -{ - return maps_open(inode, file, &proc_tid_maps_ops); -} - const struct file_operations proc_pid_maps_operations = { .open = pid_maps_open, .read = seq_read, @@ -320,10 +296,3 @@ const struct file_operations proc_pid_maps_operations = { .release = map_release, }; -const struct file_operations proc_tid_maps_operations = { - .open = tid_maps_open, - .read = seq_read, - .llseek = seq_lseek, - .release = map_release, -}; -